HTMLify

rahul verma c language program by vivek jain sir ji.c
Views: 79 | Author: rahul_verma_coder
QUESTION 1
/* CALL BY value_
SWAP THE VALUE OF THE TWO VARIABLE
*/
#include<stdio.h>
#include<conio.h>
void main(){
int a,b;
printf("Enter the value of a\n ");
scanf("%d",&a);
printf("Enter the value of b\n");
scanf("%d",&b);
printf("\nbefore swap value\n a is value : %d \n b is value : %d",a,b);
swap(a,b);
printf("\nafter swap value\n a is value : %d \n b is value : %d",a,b);
}
swap(int c,int d){
    c=c+d;
    d=c-d;
    c=c-d;
printf("\nafter swap value\n a is value %d \n b id value %d",c,d);
}
OUTPUT :
 
QUESTION 2
//wra program to printing the matrix.
#include<stdio.h>
#include<conio.h>
void main(){
int array[3][3],i,j;
for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        printf("Enter the matrix element [%d][%d] ",i,j);
        scanf("%d",&array[i][j]);
    }
}
printf("printing matrix element.....\n");
for(i=0;i<3;i++){
    printf("\n");
    for(j=0;j<3;j++){
        printf("%d\t",array[i][j]);
    }
}
} 
QUESTION 3
#include<stdio.h>
#include<conIo.h>
void main(){
	int a=0,b=1,co,c,count;
	printf("Enter the number obtain fibonacci series\n");
	scanf("%d",&co);
	printf("print dthe series is\n");
	printf("%d\n%d\n",a,b);
	count=2;
	while(count<co)
	{
		c=a+b;
		a=b;
		b=c;
		printf("%d\n",c);
		count++;
	}
}
  QUESTION 4
#include<stdio.h>
#include<conio.h>
#include<math.h>
main(){
int a,b,power;
printf("Etner the value of a ");
scanf("%d",&a);
printf("\nEnter the value of b");
scanf("%d",&b);
power=pow(a,b);
printf("\n powera^b is %d",power);
}
 
QUESTION 5
#include<stdio.h>
#include<conio.h>
main(){
int a,b,i,j;
printf("Etner the row of a ");
scanf("%d",&a);
printf("\nEnter the column of b");
scanf("%d",&b);
for(i=1;i<=a;i++)
{
    for(j=1;j<=b;j++)
    {

        printf("*");
    }
    printf("\n");
}
}
 
 
QUESTION 6
#include<stdio.h>
#include<conio.h>
main(){
int a,b;
printf("Enter your age");
scanf("%d",&a);
a==18 ? printf("you are a young boy "): printf("you are a seeet boy ");
}
 
QUESTION 7
#include<stdio.h>
#include<conio.h>
main(){
int passward;
printf("your mobile passward is 123");
printf("\n Enter the passward");
scanf("%d",&passward);
if(passward==123){
    printf("welcome");
}
else{
    printf("please enter the correct passward");

}
}
  QUESTION 8
#include<stdio.h>
#include<conio.h>
void main(){
int day;
printf("enter the number of day");
scanf("%d",&day);
switch (day)
{

        case 1 :printf("sunday");
        break;
        case 2 :printf("Monday");
        break;
        case 3:printf("tuesday");
        break;
        case 4:printf("Wednesday");
            break;
        case 5 :printf("thursday");
            break;
        case 6 :printf("Friday");
            break;
        case 7 :printf("saturday");
        break;
        default : printf("please enter the one to seven number only");


}
}
kkkklkjljk
QUESTION 9
#include<stdio.h>
#include<conio.h>
void main(){
int marks;
printf("Enter the Mraks and achieve the grade");
scanf("%d",&marks);
((marks>30) && (marks<100))? printf("you are pass my child"): printf("please do work hard because you are \"fail\"");
}
 
QUESTION 10
#include<stdio.h>
#include<conio.h>
 main(){
int x=2;
if(x=1){
    printf("x is value one");
}
else{
    printf("x is value not one");
}
} 
QUESTION 11
#include<stdio.h>
#include<conio.h>
void main(){
int a=65,b,c=97;
while(a<=90){
    printf("%c\t",a); 
    a++;
}
printf("\n");
for(b=0;b<4;b++){
    printf("and\n");
}
printf("\n");
do{
    printf("%c\t",c);
    c++;
}
while(c<123);

}
 
 
QUESTION 12
#include<stdio.h>
#include<conio.h>
void main(){
    char temp;
    printf("Enter the charactor : ");
    scanf("%c",&temp);
    temp>'a'&&temp<'z' ? 		 printf("This is a smaller letter") :
        printf("This is a capital letter");

}
  QUESTION 13
#include<stdio.h>
#include<conio.h>
void main(){
    int table_number,temp;
    printf("Enter the Table number : ");
    scanf("%d",&table_number);
    for(temp=1; temp<11; temp=temp+1){
        printf("%d*%d=%d\n",temp,table_number,temp*table_number);
    }
} 
QUESTION 14
#include<stdio.h>
#include<conio.h>
void main(){
int a,b;
printf("Enter the year : ");
scanf("%d",&a);
if(a%400==0){
    printf("leap year");
}
else if(a%100==0){
    printf("not leap year");
}
else if(a%4==0)
    {
    printf("%d is a leap year",a);
}
else{
    printf("%d is not a leap year",a);

}
}
 #include<stdio.h>
#include<conio.h>
void main(){
int a,b,c=0;
printf("Enter the vlaue of a \n");
scanf("%d",&a);
printf("Enter thte value of b \n");
scanf("%d",&b);
if(b<0){
    a=a+b;
    b=a-b;
    a=a-b;
}
if(a>=0){
    for(int i=1;i<=a;i++){
        c=c+b;
    }
}
int j;
if(a<0){
    for(j=a;j<=-1;j++){
        c=c-b;
    }
}
printf("multiplation value of a and b is %d",c);
}
 
#include<stdio.h>
#include<conio.h>
void print_namaste();
void print_bonjour();
 main(){
char user;
printf("user enter i so print namste");
printf("\n user enter f so print bonjour");
printf("Enter the charactor : \n");
scanf("%c",&user);

if(user=='i'){
     print_namaste();
}
else if(user=='f'){
     print_bonjour();
}
else
{
    printf("Enter charactor only i and f");
}
}
void print_namaste(){
printf("namaste");
}
void print_bonjour()
{
    printf("bonjour");
}
 
#include<stdio.h>
#include<conio.h>
void main(){
	hellow();
	hellow();
	hellow();
	
}
hellow(){
	printf("hellow\n");
}
 #include<stdio.h>
#include<conio.h>
void hellow();
void main(){
	hellow();
	hellow();
	hellow();
	
}
hellow(){
	printf("hellow\n");
}
  
#include<stdio.h>
#include<conio.h>
int sum(int First_value,int Second_value);
main(){
int First_value,Second_value,Temporally_variable ;
printf("Enter the first value : \n");
scanf("%d",&First_value);
printf("Enter the second value : \n");
scanf("%d",&Second_value);

Temporally_variable = sum(First_value,Second_value);
printf("sum of a and b value is %d\n",Temporally_variable);
}
 int sum(int p,int d){
 return p+d;
 }
 
#include<stdio.h>
#include<conio.h>
void main(){
int m1[3][3],m2[3][3],s[3][3];
for(int i=0;i<3;i+=1){
        for(int j=0;j<3;j=j+1){
    printf("Enter the element of first maris a%d%d : ",i+1,j+1);
    scanf("%d",&m1[i][j]);
        }
}
printf("\n\nprinting first matrix element ...\n");
for(int i=0;i<3;i++){
    for(int j=0;j<3;j+=1){
        printf("%d\t",m1[i][j]);
    }
    printf("\n");
}
for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    printf("Enter the element of second matrix a%d%d : ",i+1,j+1);
    scanf("%d",&m2[i][j]);
    }
}
printf("\n\nprintig second matrix element ....\n");
for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
     printf("%d\t",m2[i][j]);
    }
    printf("\n");
}
for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
        s[i][j]=m1[i][j]+m2[i][j];
    }
}
printf("\n\nprinting the sum of matrix first and matrix second\n");
for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
            printf("%d \t",s[i][j]);
    }
    printf("\n");
}
}
 
#include<stdio.h>
#include<conio.h>
void main(){
int a[3];
printf("Enter the chemistry mrak's : \n");
scanf("%d",&a[0]);
printf("Enter the physics mark's : \n");
scanf("%d",&a[1]);
printf("Enter the mathematic's mark's : \n");
scanf("%d",&a[2]);
printf(" chemistry mark's : %d \n physics marks : %d \n mathematic's mraks : %d",a[0],a[1],a[2]);


}
 //Question write a program to enter price of 3 item and print there final cost in with gist.
#include<stdio.h>
#include<conio.h>
void main(){
float price[3];
printf("Enter the three item price : \n");
scanf("%f",&price[0]);
scanf("%f",&price[1]);
scanf("%f",&price[2]);
printf("first price with gst is %f\n",price[0]+(price[0]*0.18));
printf("first price with gst is %f\n",price[1]+(price[1]*0.18));
printf("first price with gst is %f\n",price[2]+(price[3]*0.18));

}
 #include<stdio.h>
main(){
int a=3;
printf("a is value is %%d",a);
}
 
#include<stdio.h>
main(){
float a=3;
printf("a is value is %.2f",a);
}
 
#include<stdio.h>
main(){
float a=3;
printf("a is value is %-20f foating value",a);
}
 
#include<stdio.h>
main(){
const float a=3;//a ki value ko second time mai change nhi karsate
printf("a is value is %-20f foating value",a);

}
 
#include<stdio.h>
#define number 6
main(){
printf("number is value : %d",number);
}
 #include<stdio.h>
#define number 6
main(){
    int p=4;
    p+=1;
printf("number is value : %d",number);
printf("p is value is %d",p);
}
 
#include<stdio.h>
#include<conio.h>
void main()
{
	int a[3],i,p;
	for( i=0;i<3;i++){
		if(i==0){
		printf("Enter the physics marks : ");
		scanf("%d",&a[0]);
	}
		if(i==1){
		printf("Enter the chimistry marks : ");
		scanf("%d",&a[1]);
	}
		if(i==2){
		printf("Enter the physics marks : ");
		scanf("%d",&a[2]);
	}
	}
	printf("\n\n\nprinting the matrix element .....\n\n\n\n");
	for(p=0;p<3;p++){
		if(p==0){
			printf("physics marks is %d\n",a[0]);
		}
		else if(p==1){
			printf("chemistry marks is %d\n",a[1]);
		}
		else{
			printf("mathematic's marks is %d\n",a[2]);
		}
	}
	
	
}
 
#include<stdio.h>
#include<conio.h>
main(){
int a=1,b=2,*a1,*b1;
a1=&a;b1=&b;
printf("%d\n",a1);
printf("%d\n",b1);
a1+=1;
b1++;
printf("\n%d",a1);
printf("\n%d",b1);
printf("\n pointer first and pointer second of subtracton : %u",a1-b1);

}
 
#include<stdio.h>
main(){
int n,p;
printf("Enter the number of loop : ");
scanf("%d",&n);
for(int i=1;i<n+1;i++){
    printf("%d\n",i);
    p=p+i;
}
printf("total sum of number : %d",p);
}
 
#include<stdio.h>
main(){
int n,f=1,i;
printf("Enter the value of factorial : ");
scanf("%d",&n);
for( i=1; i<n+1;i++){
    f=f*i;
}
printf("factorial is %d",f);
}
 
#include<stdio.h>
main(){
    int a[100],*p,n;
    p=&a[0];
    printf("Enter the running array : ");
    scanf("%d",&n);
    for(int i=0;i<n;i+=1){
  printf("Enter the array indax a%d : ",i+1);
  scanf("%d",(p+i));
    }
printf("printing the array element ......\n");
for(int i=0;i<n;i++){
    printf("%d\n",*(p+i));
}
}
 
#include<stdio.h>
void l(int a[],int n);
void main(){
int  a[]={1,2,3,4,5,6};
  l(a,6);

}
void l(int a[],int n){
       for(int i=0;i<n;i++){
       printf("%d\t",a[i]);
       }
       printf("\n");
       }
 
#include<stdio.h>
main(){
int a,b,c;
printf("Enter the value of a,b and c : ");
scanf("%d%d%d",&a,&b,&c);
switch(a>b)
{
    switch(a>b)
    {
        case 1: printf("%d is greatest value ",a);
    default : printf("%d is greatest value",b);
    }

default :
    switch(c>b)
    {
    case 1: printf("%d is a greatest value ",c);
    default :
        printf("%d is a greatest value ",b);
    }
}
}
 #include<stdio.h>
main(){
int a,b,c;
printf("Enter the value of a : ");
scanf("%d",&a);
printf("Enter the value of b : ");
scanf("%d",&b);
printf("Enter the value of c : ");
scanf("%d",&c);
if(a>b&&a>c){
    printf("%d is a gretest value",a);
}
else if(b>a&&b>c){
    printf("%d is a greatest value",b);
}
else 
    {
    printf("%d is a greatest value ",c);
}
}
 
#include<stdio.h>
main(){
char n;
printf("Enter the charactor : ");
scanf("%c",&n);
switch(n){
case 'a' :
    printf(" %c is a vowel",n);
    break;
case 'e' :
    printf(" %c is a vowel",n);
    break;
case 'i' :
    printf(" %c is a vowel",n);
    break;
case 'o' :
    printf(" %c is a vowel",n);
    break;
case 'u' :
    printf(" %c is a vowel",n);
    break;
case 'A' :
    printf(" %c is vowel",n);
    break;
case 'E' :
    printf(" %c is vowel",n);
    break;
case 'I' :
    printf(" %c is vowel",n);
    break;
case 'O' :
    printf(" %c is vowel",n);
    break;
case 'U' :
    printf("%c is vowel",n);
    break;
default :
    printf(" %c is a constant",n);
}
}
 
#include<stdio.h>
main(){
char n;
printf("Enter the charactor : ");
scanf("%c",&n);
if(n=='a'){
    printf("%c is a vowel",n);
}
else if(n=='e')
{
    printf("%c is a vowel",n);
}else if(n=='i')
{
    printf("%c is a vowel",n);
}else if(n=='o')
{
    printf("%c is a vowel",n);
}else if(n=='u')
{
    printf("%c is a vowel",n);
}else if(n=='A')
{
    printf("%c is a vowel",n);
}else if(n=='E')
{
    printf("%c is a vowel",n);
}else if(n=='I')
{
    printf("%c is a vowel",n);
}else if(n=='O')
{
    printf("%c is a vowel",n);
}else if(n=='U')
{
    printf("%c is a vowel",n);
}
else{
    printf("%c is consonant ",n);
}
}
 
#include<stdio.h>
struct n{
int roll_no;
char name[100];
}n1;
main(){
printf("Enter your name : ");
gets(n1.name);
printf("Enter the roll no : ");
scanf("%d",&n1.roll_no);
printf("your roll no is %d\n",n1.roll_no);
printf("name is %s",n1.name);
}
 
#include<stdio.h>
struct n{
int roll_no;
char name[100];
}n1[5];
main(){
    for(int i=0;i<5;i++){
printf("Enter your name : \n");
scanf("%s",&n1[i].name);
printf("Enter the roll no : \n");
scanf("%d",&n1[i].roll_no);
}
for(int i=0;i<5;i++){
printf("name is ");
puts(n1[i].name);
printf("\nyour roll no is %d\n",n1[i].roll_no);
}
}
 
//input kilometers and find meter, centimeters ,feet and inches.
#include<stdio.h>
main(){
float km,m,cm,ft,inch;
printf("Enter the distace in kilometers : ");
scanf("%f",&km);
m=km*1000;
cm=m*100;
inch= cm/2.54;
ft=inch/12;
printf("distance is meters : %f ",m);
printf("\ndistance is centimeters : %f ",cm);
printf("\ndistance is inches : %f ",inch);
printf("\ndistance is feet : %f ",ft);
}

Apna college 
Chapter 11
Chapter name  dynamic memeory allotcation
#include<stdio.h>
#include<stdlib.h>
main(){
int *ptr;
ptr=(int*)malloc(5*sizeof(int));
ptr[0]=1;
ptr[1]=1;
ptr[2]=1;
ptr[3]=1;
ptr[4]=1;
for(int i=0;i<5;i++){
    printf("%d",ptr[i]);
}
}
 #include<stdio.h>
#include<stdlib.h>
main(){
float *s;
s=(float*)malloc(5*sizeof(float));
s[0]=1;
s[1]=2;
s[2]=3;
s[3]=4;
s[4]=5;
for(int i=0;i<5;i++){
    printf("%f\n",s[i]);
}
}
 
#include<stdio.h>
#include<stdlib.h>
main(){
float *s;
s=(int*)calloc(5,sizeof(float));
for(int i=0;i<5;i++)
printf("%.2f\n",s[i]);
}
 
#include<stdio.h>
#include<stdlib.h>
main(){
int n,*p;
printf("Enter the value : ");
scanf("%d",&n);
p=(int*)calloc(n,sizeof(int));
for(int i=0;i<n;i++){
    printf("%d\n",p[i]);
}


}
 
#include<stdio.h>
#include<stdlib.h>
main(){
float a,*b;
b=(char*)calloc(5,sizeof(char));
printf("printing the element \n");
for(int i=0;i<5;i++){
    printf("%s\n",b[i]);
}
}
 #include<stdio.h>
#include<stdlib.h>
main(){
int *a,n;
printf("Enter the value of n : ");
scanf("%d",&n);
a=(int*)calloc(n,sizeof(int));
for(int i=0;i<n;i++)
{
    printf("%d\n",a[i]);
}
free(a);
a=(int*)calloc(2 ,sizeof(int));
printf("\n\n\t");
for(int i=0;i<2;i++){
    printf("%d\t",a[i]);
}
printf("\n\n");
}
 
#include<stdio.h>
main()
{
    int *a;
    a=(int*)calloc(5,sizeof(int));
    printf("Enter the 5 Element \n\n");
    for(int i=0; i<5; i++)
    {
        printf("Enter the Element %d : ",i+1);
        scanf("%d",&a[i]);
    }
    realloc(a,8);
    printf("\nEnter the 8 element \n");
    for(int i=0;i<8;i++){
        printf("Enter the element %d : ",i+1);
        scanf("%d",&a[i]);
    }
    for(int i=0;i<8;i+=1){
        printf("%d\n",a[i]);
    }


}
 
#include<stdio.h>
main(){
int *p,c;
p=(int*)calloc(15,sizeof(int));
printf("printing the even number : \n");
p[0]=1;
p[1]=3;
p[2]=5;
p[3]=7;
p[4]=9;
for(int i=0;i<5;i++){
    printf("%d\n",p[i]);
}
p=realloc(p,6);
printf("printing the odd number : \n");
p[0]=2;
p[1]=4;
p[2]=6;
p[3]=8;
p[4]=10;
p[5]=12;
for(int i=0;i<6;i++){
    printf("%d\n",p[i]);
}
}
 
Apna college 
Chapter 10
Chapter name file input/output

#include<stdio.h>
main(){
	FILE *p;
	p=fopen("yy.txt","r");
	if(p==NULL){
		printf("file does not exist \n");
	}
	else{
	fclose(p);	
	}
	
	
}
 
//file name y.txt
my_name_is_rahul_verma
//file name n.c
#include<stdio.h>
main(){
FILE *p;
p=fopen("y.txt","r");
//if(p==NULL){
//    printf("file does not access");
//    }
//    else{
//        fclose(p);
//    }
char ch[100];
fscanf(p,"%s",&ch);
printf("charactor is %s",ch);
fclose(p);
}
 
//rahu.txt
rahul
    //WITH OUT USING ARRAY
    #include<stdio.h>
    main(){
    FILE *p;
    p=fopen("rahu.txt","r");
    char ch;
    fscanf(p,"%c",&ch);
    printf("%c",ch);
    fscanf(p,"%c",&ch);
    printf("%c",ch);
    fscanf(p,"%c",&ch);
    printf("%c",ch);
    fscanf(p,"%c",&ch);
    printf("%c",ch);
    fscanf(p,"%c",&ch);
    printfZ	("%c",ch);
    fclose(p);
    }

 
//u.txt
4
5
6
//n.c
#include<stdio.h>
main(){
FILE *p;
int ch;
p=fopen("u.txt","r");
fscanf(p,"%d",&ch);
printf("first number is %d",ch);
fscanf(p,"%d",&ch);
printf("\nsecond number is %d",ch);
fscanf(p,"%d",&ch);
printf("\nthird number is %d ",ch);
fclose(p);
}
 
//p.txt
Mango
//n.c
#include<stdio.h>
main(){
FILE *p;
p=fopen("p.txt","a");
fprintf(p,"%c",'r');
fprintf(p,"%c",'a');
fprintf(p,"%c",'h');
fprintf(p,"%c",'u');
fprintf(p,"%c",'l');
}
 
 
 
#include<stdio.h>
main(){
char n;
FILE *p;
p=fopen("ram.txt","r");
for(int i=0;i<=100;i++){
    printf("%c",fgetc(p));
}
}
 	
//using fputs function
Ram.txt
Rahul
n.c
#include<stdio.h>
main(){
char n;
FILE *p;
p=fopen("ram.txt","w");
fputc('m',p);
fputc('a',p);
fputc('n',p);
fputc('g',p);
fputc('o',p);
}
 
 
#include<stdio.h>
main(){
    int a=3;
    float b=3;
printf("%d",(int)(a+b));
}





c program using dsa











//Question 1 .
#include<stdio.h>
#include<stdlib.h>
#define MAX 10
int stack_arr[MAX];
int top=-1;
void push(int item);
int pop();
int peep();
int isempty();
int isfull();
void display();
void main(){
    int choice,item;
    while(1)
    {
    printf("1.push\n");
    printf("2.pop\n");
    printf("3.Display the top element \n");
    printf("4.Display all the stack elements \n");
    printf("5. Quit \n");
    printf("Enter the your chaoice : ");
    scanf("%d",&choice);
    switch(choice)
    {
    case 1 :
        printf("Enter the item to be pushed : ");
        scanf("%d",&item);
        push(item);
        break;
    case 2 :
        item=pop();
        printf("popped item is %d\n",item);
        break;
    case 3 :
        printf("item at the top is : %d\n",peep());
        break;
    case 4 :
        display();
        break;
    case 5 :
    	7;
        exit (1);
    default :
        printf("Wrong choice\n");

    }

    }
}
void push(int item){
if(isfull())
{
    printf("stack Overflow \n");
    return ;
}
top=top+1;
stack_arr[top]=item;
}
int pop()
{

    int item ;
    if(isempty()){
        printf("stack underflow\n");
        exit(1);
    }
    item=stack_arr[top];
    top=top-1;
    return item;
}
int peep(){
if(isempty()){
printf("stack underflow \n");
exit(1);
}
return stack_arr[top];
}
int isempty(){
if(top==-1)
    return 1;
else
    return 0;
}
int isfull(){
if(top==MAX-1)
    return 1;
else
    return 0;
}
void display()
{
    int i;
    if(isempty())
    {
        printf("stack is empty\n");
        return ;
    }
printf("stack element : \n\n");
for(i=top;i>=0;i--)
    printf("%d\n",stack_arr[i]);
printf("\n");
}







dsa program 





//menu driven program
#include<stdio.h>
main(){
int c,a,b,choice;
char u;
do{
printf("Main Menu");
printf("\n1.Addition");
printf("\n2.Subtraction");
printf("\n3.Multiplecation");
printf("\n0.eixt\n");
printf("Enter your choice : ");
scanf("%d",&choice);
if(choice==1){
printf("\nEnter the value of a : ");
scanf("%d",&a);
printf("\nEnter the value of b : ");
scanf("%d",&b);
c=a+b;
printf("sum of a and b value : %d",c);
}
else if(choice==2){
    printf("Enter the value of a : ");
    scanf("%d",&a);
    printf("\nEnter the value of b : ");
    scanf("%d",&b);
    c=a*b;
    printf("\nmultiplecation of a and b value : %d",c);
}
else if(choice==3){
    printf("Enter the value of a : ");
    scanf("%d",&a);
    printf("\nEnter the vlaue of b : ");
    scanf("%d",&b);
    c=a-b;
    printf("subtaction of a and b value : %d",c);
}
else if(choice==0){
    exit(0);
}
else {
    printf("you have choice wrong\n");
}
printf("\ndo wish you continue your ");
scanf(" %c",&u);
}
while(u=='y'||u=='Y');
}
 
 
#include<stdio.h>
void push(int a[],int *top,int size){
if(*top==size-1){
printf("overflow and full");
}
else{
    (*top)++;
    printf("\nEnter the element : ");
    scanf("%d",&a[*top]);
}
}
void pop(int a[],int *top,int size){
if(*top==-1){
    printf("under flow ");
}
else{
    printf("delete is element %d ", a[*top]);
    (*top)--;
    printf ("\nnext elemetn is %d ",a[*top]);
}
}
main()
{
    int a[20],top,size,choice;
    top=-1;
    printf("do you close this proces so press 1234 \n");
    printf("Enter the size of stack : ");
    scanf("%d",&size);
    printf("Main menu \n");
    printf("press 1 push \n");
    printf("press 2 pop ");
    for(int i=0;;i++){
    printf("\nEnter your choice : ");
    scanf("%d",&choice);
    switch(choice){
    case 1 : push(a,&top,size);
    break;
    case 2 : pop(a,&top,size);
    break;
    case 1234 :
        exit(0);
    default :
        printf("invalid choice ");
    }
    }

}
 

















































































































































 




























































































































Comments